import request, { download } from '@/utils/request'
/**
 * 角色信息表 Api
 *
 * @author EasyAdmin ( 1073602@qq.com )
 * @date 2025-08-25
 */
export default {

  /**
   * 分页查询
   * @param query 查询参数
   */
  page: (query: any) => {
    return request.get('/admin/system/role/page', { params: query })
  },

  /**
   * 查询列表
   * @param query 查询参数
   */
  list: (query: any) => {
    return request.get('/admin/system/role/list', { params: query })
  },

  /**
   * 查询详细
   * @param query 查询参数
   */
  getById: (id: string) => {
    return request.get('/admin/system/role/' + id)
  },

  /**
   * 新增
   * @param data 新增数据
   */
  add: (data: any) => {
    return request.post('/admin/system/role', data)
  },

  /**
   * 修改
   * @param data 修改数据
   */
  update: (data: any) => {
    return request.put('/admin/system/role', data)
  },

  /**
   * 删除
   * @param ids 删除Ids
   */
  delete: (ids: any) => {
    return request.delete('/admin/system/role/' + ids)
  },

  /**
   * 导出Excel
   * @param filename Excel文件名称
   * @param query 查询参数
   */
  download: (query: any, filename: string) => {
    download("/admin/system/role/export", { ...query }, filename + '.xlsx', {});
  },

  /**
   * 角色数据范围
   * @param data 
   * @returns 
   */
  dataScope: (data: any) => {
    return request.put('/admin/system/role/dataScope', data)
  },

  /**
   * 角色状态修改
   * @param roleId 
   * @param status 
   * @returns 
   */
  changeStatus: (roleId: any, status: any) => {
    const data = {
      roleId,
      status
    }
    return request.put('/admin/system/role/changeStatus', data)
  },

  /**
   * 根据角色ID查询部门树结构
   * @param roleId 
   * @returns 
   */
  deptTree: (roleId: any) => {
    return request.get('/admin/system/role/deptTree/' + roleId)
  }

}